home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_multifile.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  2KB  |  38 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import mimetools
  5. import multifile
  6. import cStringIO
  7. msg = 'Mime-Version: 1.0\nContent-Type: multipart/mixed;\n        boundary="=====================_590453667==_"\nX-OriginalArrivalTime: 05 Feb 2002 03:43:23.0310 (UTC) FILETIME=[42D88CE0:01C1ADF7]\n\n--=====================_590453667==_\nContent-Type: multipart/alternative;\n        boundary="=====================_590453677==_.ALT"\n\n--=====================_590453677==_.ALT\nContent-Type: text/plain; charset="us-ascii"; format=flowed\n\ntest A\n--=====================_590453677==_.ALT\nContent-Type: text/html; charset="us-ascii"\n\n<html>\n<b>test B</font></b></html>\n\n--=====================_590453677==_.ALT--\n\n--=====================_590453667==_\nContent-Type: text/plain; charset="us-ascii"\nContent-Disposition: attachment; filename="att.txt"\n\nAttached Content.\nAttached Content.\nAttached Content.\nAttached Content.\n\n--=====================_590453667==_--\n\n'
  8.  
  9. def getMIMEMsg(mf):
  10.     global boundaries, linecount
  11.     msg = mimetools.Message(mf)
  12.     if msg.getmaintype() == 'multipart':
  13.         boundary = msg.getparam('boundary')
  14.         boundaries += 1
  15.         mf.push(boundary)
  16.         while mf.next():
  17.             getMIMEMsg(mf)
  18.         mf.pop()
  19.     else:
  20.         lines = mf.readlines()
  21.         linecount += len(lines)
  22.  
  23.  
  24. def test_main():
  25.     global boundaries, linecount
  26.     boundaries = 0
  27.     linecount = 0
  28.     f = cStringIO.StringIO(msg)
  29.     getMIMEMsg(multifile.MultiFile(f))
  30.     if not boundaries == 2:
  31.         raise AssertionError
  32.     if not linecount == 9:
  33.         raise AssertionError
  34.  
  35. if __name__ == '__main__':
  36.     test_main()
  37.  
  38.